package com.example.bbbb.AOP.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-01-06
 * Time: 0:02
 */

@Aspect
@Component
public class MyAspect {

    @Around("execution(public int com.example.bbbb.AOP.service.impl.CalcServiceImpl.*(..))")
    public Object aroundNotify(ProceedingJoinPoint pjp) throws Throwable {
        Object retValue = null;
        System.out.println("@Around 前");
        // 执行方法
        retValue = pjp.proceed();
        System.out.println("Around 后");
        return retValue;
    }


    @Before("execution(public int com.example.bbbb.AOP.service.impl.CalcServiceImpl.*(..))")
    public void beforeNotify() {
        System.out.println("@Before");
    }

    @AfterReturning("execution(public int com.example.bbbb.AOP.service.impl.CalcServiceImpl.*(..))")
    public void afterReturningNotify() {
        System.out.println("@AfterReturning");
    }

    @AfterThrowing("execution(public int com.example.bbbb.AOP.service.impl.CalcServiceImpl.*(..))")
    public void afterThrowingNotify() {
        System.out.println("@AfterThrowing");
    }

    @After("execution(public int com.example.bbbb.AOP.service.impl.CalcServiceImpl.*(..))")
    public void afterNotify() {
        System.out.println("@After");
    }


}
